package com.shop.vo;

import com.shop.core.ResultCode;
import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public class ResultJson<T> {
    private Integer code;
    private T content;
    private String message;

    public static <T> ResultJson<T> getInstance(ResultCode resultCode, T content, String message) {
        return new ResultJson<>(resultCode.getCode(), content, message);
    }

    //成功
    public static <T> ResultJson<T> success(T content, String message) {
        return getInstance(ResultCode.SUCCESS, content, message);
    }

    public static <T> ResultJson<T> success(T content) {
        return success(content, null);
    }


    //失败
    public static <T> ResultJson<T> failed(T content, String message) {
        return getInstance(ResultCode.FAILED, content, message);
    }

    public static <T> ResultJson<T> failed( String message) {
        return failed(null, message);
    }
}
